package entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties({"email","age"})
public class Emp implements Serializable {

    private Integer id;

    @JsonProperty("username")
    @NotBlank(message = "姓名不能为空")
    private String name;

    @JsonIgnore
    @Length(min = 3,max = 7)
    private String password;

    @NotBlank
    @Email
    private String email;

    @Range(min = 1,max = 120,message = "非人类")
    private Integer age;

    @Pattern(regexp = "^\\d{3,4}-\\d{8}$")
    private String phone;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date birthday;
}
